home *** CD-ROM | disk | FTP | other *** search
- Path: admaix.sunydutchess.edu!ub!newserve!rebecca!rpi!not-for-mail
- From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: Q: stack corrupted before main()?
- Date: 8 Feb 1996 16:35:01 -0000
- Organization: unknown
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: vandevod@cs.rpi.edu
- Message-ID: <4fd8nl$9nb@netlab.cs.rpi.edu>
- References: <4f8423$kp9@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Thu, 8 Feb 96 16:23:40 +0100
-
- In article <4f8423$kp9@netlab.cs.rpi.edu> Jacek Surazski
- <jaceks@stud.unit.no> writes:
-
- |> The project I am currently working on is exhibiting the following behavior:
- |> the stack is corrupted even before control enters main(). That is, when I
- |> run it under a debugger and view the stack, it shows names of non-existent
- |> functions
- |> even as the control pointer is still on the main() header. If I try to step
- |> through the program, the stack shows new non-existant, and occasionally
- |> existant but incorrect functions, whenever I step into a function in the
- |> code.
-
- The most likely explination is that the debugger is looking at the
- wrong binary for the symbols. Of course, `non-existant' functions are
- to be expected, since (presumably) the debugger also shows the system
- functions which invoke main. (Under Unix, this would correspond to
- crt0, but I don't know what the conventions are for MS-DOS.) Since
- you say later that you are compiling under DOS, is it possible that
- you have somehow mixed your compilation modes. I can imagine that a
- debugger would have considerable problems if it thinks that the
- program was compiled in large, when in fact it was compiled in small.
- (Again, I'm not familiar with modern DOS software, but is it possible
- that your main module was compiled in small, then linked with the
- large model start-up routines, or vice-versa?)
-
- |> The project is written for dos, and I am using bc 3.1. I've tried to "boil
- |> down" the problem to as small a piece of code as possible, but it proved
- |> a bit bewildering, as no single chunk appeared to be responsible. Removing
- |> miscelenous bits from here and there seemed to allivate the problem, but
- |> these bits apparently had nothing in common. I have come to the conclusion,
- |> that perhaps this is a configuration problem?
-
- The symptoms you describe are typical of pointer problems. Removing a
- bit of code having nothing to do with the problem will change the
- addresses of the rest of the program (and data) in memory; the write
- through an uninitialized pointer will then modify different data (thus
- changing the symptoms)..
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-